package com.lin.sppringbootdemo.enums;

public enum ResultEnum {
    UNKNOW_ERROE(-1, "未知错误"),
    SUCCESS(0, "成功"),
    SMALL(100, "小学"),
    MIDOUN(101, "中学");

    private int code;
    private String msg;

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    ResultEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    ResultEnum(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
    }

    public static ResultEnum getEnumByCode(int code) {
        for (ResultEnum resultEnum : ResultEnum.values()) {
            if (resultEnum.getCode() == code) {
                return resultEnum;
            }
        }
        return null;
    }


}
